// Direct way is blocked for x time
// Map: Atlantic Seawall Battery (Last Man Standing mode)
// BSP: battery

game_manager
{
	spawn
	{
		create
		{			
		scriptname "neuetuer"
		targetname "neuetuer"
		classname "func_door_rotating"
		allowteams "5"
		origin "1111 -3952 941"
		type "5"
		model "*2"
		}
		
//--------------------- Anti Jump Trigger 1 ---------------------
		
		create
		{
			classname "trigger_multiple"
			spawnflags "2" // allied_only
			target "anti_jump_entities1"
			scriptname "anti_jump_trigger1"
			origin "1970 -3986 1240"
			mins "-100 -20 -10"
			maxs "100 20 10"
		}

		create
		{
			classname "target_speaker"
			targetname "anti_jump_entities1"
			scriptname "anti_jump_trigger1"
			angle "90"
			noise "sound/weapons/impact/flesh1.wav"
			origin "1957 -3986 1240"
		}

		create
		{
			classname "target_push"
			targetname "anti_jump_entities1"
			scriptname "anti_jump_trigger1"
			angle "90"
			origin "1957 -3986 1240"
		}

		create
		{
			classname "target_print"
			targetname "anti_jump_entities1"
			scriptname "anti_jump_trigger1"
			angle "90"
			origin "1957 -3986 1240"
			message "This Trickjump is not allowed at this time! Please wait some minutes!"
			spawnflags "4"
		}
		
//--------------------- Anti Jump Trigger 2 ---------------------

		create
		{
			classname "trigger_multiple"
			spawnflags "2" // allied_only
			target "anti_jump_entities2"
			scriptname "anti_jump_trigger2"
			origin "1150 -4010 940"
			mins "-8 -250 -139"
			maxs "8 250 139"
		}
		
		create
		{
			classname "target_print"
			targetname "anti_jump_entities2"
			scriptname "anti_jump_trigger2"
			angle "90"
			origin "1150 -4010 940"
			message "Wait some minutes before you go this way!"
			spawnflags "4"
		}
		
//---------------------------------------------------------------

		// Ragnar begin: Create bunker planks stuff.
        // To create the Bunker Assault Ramp simply clone the Beach Assault Ramp (aka the "beach planks") and translate it by (250, -1135, 160).
        // Construction stuff is translated by (100, -1545, 424) i.e. inside the bunker

        // Create TOI so that it boxes the construction materials: (1792, -4288, 1152)x(1896, -4420, 1220)
        create
        {
            scriptname "bunkerplanks_toi"
            targetname "bunkerplanks_toi"
            target     "bunkerplanks"
            classname  "trigger_objective_info"
            infoAllied "Build Bunker Assault Ramp"
            infoAxis   "Destroy Bunker Assault Ramp"
            shortname  "Allied Bunker Assault Ramp"
            track      "the Allied Bunker Assault Ramp"
            spawnflags "2"
            origin     "1844 -4354 1186"
            mins       "-52 -66 -34"
            maxs       "72 66 34"
        }

        // Add some crates as materials.
        create
        {
            scriptname "bunkerplanks_materials"
            targetname "bunkerplanks_materials"
            classname  "misc_gamemodel"
            angle      "90"
            origin     "1850 -4350 1152"                                    // Places on the other side of the flag relativ to the bach materials materials due to available space.
            skin       "models/mapobjects/cmarker/allied_crates.skin"
            model      "models/mapobjects/cmarker/cmarker_crates.md3"
        }

        // Add a trigger_hurt which kills all who get caught inside the materials when the bunker planks are destryed.
        create
        {
           scriptname "bunkerplanks_material_hurt"
           targetname "bunkerplanks_material_hurt"
           spawnflags 24                                       // SLOW+NO_PROTECTION
           classname  "trigger_hurt"
           //dmg        500                                      // Instant gib.
           sound      "sound/player/hurt_barbwire.wav"
           origin     "1844 -4354 1186"                        // Same coordiantes as the TOi, but smaller in size.
           mins       "-30 -30 -20"
           maxs       "30 30 20"
        }

        // Clone clipping for material boxes.
        // Beach planks materials are at  (1780, -2672,  756)
        // Bunker planks materials are at (1850, -4350, 1152)
        // Translate by                   (  70, -1678,  396)
        create
        {
            // No faceangles
            model      "*7"
            scriptname "bunkerplanks_clip"
            targetname "bunkerplanks_materials_clip"
            classname  "func_static"
            origin     "70 -1678 396"
        }

        // Add a flag to the materials.
        create
        {
            scriptname "bunkerplanks_flag"
            targetname "bunkerplanks_flag"
            classname  "misc_gamemodel"
            spawnflags "2"
            origin     "1866 -4389 1202"                                            // Beach Assault Ramp flag is at (1746, -2636, 778), translate by (120, -1755, 424), flag pole is 2 units wide
            angle      "90"                                                         // Turn around 180°, so it doesn't intersect with the wall.
            frames     "190"
            modelscale "0.4"
            model      "models/mapobjects/cmarker/cmarker_flag.md3"
            skin       "models/mapobjects/cmarker/allied_cflag.skin"
        }

        // Clone flag post.
        // Note: Place it into the corner, because of vis issues.
        create
        {
            // No faceangles
            model      "*9"
            scriptname "bunkerplanks_clip"
            targetname "bunkerplanks_materials_clip"
            classname  "func_static"
            origin     "120 -1755 424"
        }

        // Clone a func_constructible to use it for the bunkerplanks.
        // Note: This already includes a ramp model but it seems the vis is somehow built in, so the ramp isn't visible from some locations.
        create
        {
          // No faceangles
            model      "*1"
            scriptname "bunkerplanks_model"
            targetname "bunkerplanks_model"
            classname  "func_static"
            origin     "230 -1135 160"                                             // Translate by (230, -1135, 160)
        }

        create
        {
            // No faceangles
            model      "*11"
            scriptname "bunkerplanks"
            targetname "bunkerplanks"
            classname  "func_constructible"
            origin     "1950 -3850 1200"
            spawnflags "8"
        }

        // Create some kind of fundament so the legs of the large bunker planks don't stick into the air.
        create
        {
            scriptname "bunkerplanks_spool"
            targetname "bunkerplanks_spool"
            origin "1860 -3895 919"
            angles "90 0 0"
            classname "misc_gamemodel"
            modelscale 0.75
            mins "-6 -33 -11"
            maxs "60 33 15"
            contents 0 // PLAYERCLIP
            clipmask 0 // PLAYERCLIP
            model "models/mapobjects/spool_sd/spool.md3"
        }

        // Add some tires which can players use as step to the bunker ramp.
        // Lowest tire.
        create
        {
            scriptname "bunkerplanks_step_1"
            targetname "bunkerplanks_step_1"
            origin "2025 -3854 900"
            angles "0 180 90"
            classname "misc_gamemodel"
            modelscale 1
            contents 1
            mins "-20 -20 -100"
            maxs "20 20 52"
            clipmask 1
            model "models/mapobjects/blitz_sd/blitzwheelsf.md3"
        }

        // Center tire.
        create
        {
            scriptname "bunkerplanks_step_2"
            targetname "bunkerplanks_step_2"
            origin "2025 -3855 913"
            angles "0 190 90"
            classname "misc_gamemodel"
            modelscale 1
            contents 1
            mins "-20 -20 -100"
            maxs "20 20 52"
            clipmask 1
            model "models/mapobjects/blitz_sd/blitzwheelsf.md3"
        }

        // Top tire.
        create
        {
            scriptname "bunkerplanks_step_3"
            targetname "bunkerplanks_step_3"
            origin "2024 -3855 926"
            angles "0 170 90"
            classname "misc_gamemodel"
            modelscale 1
            contents 1
            mins "-20 -20 -100"
            maxs "20 20 52"
            clipmask 1
            model "models/mapobjects/blitz_sd/blitzwheelsf.md3"
        }

        // Don't miss to add the 4th tire of the set ;)
        create
        {
            scriptname "bunkerplanks_tire"
            targetname "bunkerplanks_tire"
            origin "1880 -3870 901"
            angles "0 0 31"
            classname "misc_gamemodel"
            modelscale 1
            contents 1
            mins "-20 -20 -100"
            maxs "20 20 45"
            clipmask 1
            model "models/mapobjects/blitz_sd/blitzwheelsf.md3"
        }
        // Ragnar end: Create bunker planks stuff.

		// Game rules
		wm_number_of_objectives 1
		wm_set_round_timelimit	10

		wait 100
		setautospawn	"Allied Spawn"	1
		setautospawn	"Axis Spawn"	0

		// start triggered loops on/off as required (eg: command post radio sounds)
		disablespeaker allies_compost_sound
		disablespeaker axis_compost_sound
		disablespeaker allies_compost_sound_lms
		disablespeaker axis_compost_sound_lms
		disablespeaker doorcontrols_sound

		wait 1000
		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"

		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		wm_teamvoiceannounce 0 "axis_hq_compost_construct"

		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		// *---------------------------------------------------------------------------------*

		//wait 150000
		wait 5000
		trigger neuetuer open
		trigger anti_jump_trigger1 kill
		trigger anti_jump_trigger2 kill
		trigger newdoor open
		construct bunkerplanks
		wait 5000
		trigger frontdoor_trigger1 off
	}
}

// ================================================
// =========== SPAWN POINT CONTROLS ===============
// ================================================
// description			: team_wolf_objectives	: spawns
// Allied East Beach 	: eastbeach_wobj		: eastbeach_spawns
// Allied West Beach 	: westbeach_wobj		: westbeach_spawns
// Axis Main Bunker		: mainbunker_wobj		: mainbunker_spawns
// East Bunker			: eastbunker_wobj		: eastbunker_spawns
// West Bunker			: westbunker_wobj		: westbunker_spawns

eastbeach_spawns
{
	spawn
	{
		remove
	}
}

eastbeach_wobj
{
	spawn
	{
		remove
	}
}

westbeach_spawns
{
	spawn
	{
		remove
	}
}

westbeach_wobj
{
	spawn
	{
		remove
	}
}

mainbunker_spawns
{
	spawn
	{
		remove
	}
}

mainbunker_wobj
{
	spawn
	{
		remove
	}
}

eastbunker_spawns
{
	spawn
	{
		remove
	}
}

eastbunker_wobj
{
	spawn
	{
		remove
	}
}

westbunker_spawns
{
	spawn
	{
		remove
	}
}

westbunker_wobj
{
	spawn
	{
		remove
	}
}
// ============== end spawn point controls ========
// ================================================

fan01
{
	spawn
	{
		wait 50
		setrotation	0 0 -600
	}
}

fan02
{
	spawn
	{
		wait 50
		faceangles 0 270 0 1
		setrotation	0 0 -300
	}
}

lighthouse_light
{
	spawn
	{
		wait 100
		setrotation	0 15 0
	}
}

hatch_controller
{
	activate
	{
		trigger hatch open
	}
}

hatch
{
	trigger open
	{
		accum 0 abort_if_equal 1
		accum 0 set 1
		wait 50
		playsound sound/movers/doors/door5_open.wav
		faceangles 0 0 270 1500

		wait 3000
		trigger hatch close
	}

	trigger close
	{
		wait 50
		playsound sound/movers/doors/door5_close.wav
		faceangles 0 0 0 1500
		playsound sound/movers/doors/door5_endc.wav

		accum 0 set 0
	}
}

// -----------------------------
// Gun Emplacements
// -----------------------------

// West Beach
browning_clip_1
{
	spawn
	{
		wait 200
		trigger browning_clip_1 setup
	}

	trigger setup
	{
		setstate browning_1 invisible
		setstate browning_sbags_1 invisible

		setstate browning_materials_1 invisible
		setstate browning_materials_clip_1 invisible
		setstate browning_flag_1 invisible
		setstate browning_1_toi invisible
	}

	buildstart final
	{
		setstate browning_1 underconstruction
		setstate browning_sbags_1 underconstruction

		setstate browning_materials_1 default
		setstate browning_materials_clip_1 default
		setstate browning_flag_1 default
	}

	built final
	{
		setstate browning_1 default
		setstate browning_sbags_1 default

		setstate browning_materials_1 invisible
		setstate browning_materials_clip_1 invisible
		setstate browning_flag_1 invisible

		wm_announce "The Allied West beach MG Nest has been constructed."
	}

	decayed final
	{
		setstate browning_1 invisible
		setstate browning_sbags_1 invisible

		setstate browning_materials_1 default
		setstate browning_materials_clip_1 default
		setstate browning_flag_1 default
	}

	death
	{
		setstate browning_1 invisible
		setstate browning_sbags_1 invisible
		repairmg42 browning_1
		setstate browning_materials_1 default
		setstate browning_materials_clip_1 default
		setstate browning_flag_1 default

		wm_announce "The Allied West beach MG Nest has been destroyed."
	}
}

// East Beach
browning_clip_2
{
	spawn
	{
		wait 200
		trigger browning_clip_2 setup
	}

	trigger setup
	{
		setstate browning_2 invisible
		setstate browning_sbags_2 invisible

		setstate browning_materials_2 invisible
		setstate browning_materials_clip_2 invisible
		setstate browning_flag_2 invisible
		setstate browning_2_toi invisible
	}

	buildstart final
	{
		setstate browning_2 underconstruction
		setstate browning_sbags_2 underconstruction

		setstate browning_materials_2 default
		setstate browning_materials_clip_2 default
		setstate browning_flag_2 default
	}

	built final
	{
		setstate browning_2 default
		setstate browning_sbags_2 default

		setstate browning_materials_2 invisible
		setstate browning_materials_clip_2 invisible
		setstate browning_flag_2 invisible

		wm_announce "The Allied East beach MG Nest has been constructed."
	}

	decayed final
	{
		setstate browning_2 invisible
		setstate browning_sbags_2 invisible

		setstate browning_materials_2 default
		setstate browning_materials_clip_2 default
		setstate browning_flag_2 default
	}

	death
	{
		setstate browning_2 invisible
		setstate browning_sbags_2 invisible
		repairmg42 browning_2
		setstate browning_materials_2 default
		setstate browning_materials_clip_2 default
		setstate browning_flag_2 default

		wm_announce "The Allied East beach MG Nest has been destroyed."
	}
}

// Axis Main Bunker interior
mg42_clip_1
{
	spawn
	{
		wait 200
		trigger mg42_clip_1 setup
	}

	trigger setup
	{
		setstate mg42_1 invisible

		setstate mg42_materials_1 invisible
		setstate mg42_materials_clip_1 invisible
		setstate mg42_flag_1 invisible
		setstate mg42_1_toi invisible
	}

	buildstart final
	{
		setstate mg42_1 underconstruction

		setstate mg42_materials_1 default
		setstate mg42_materials_clip_1 default
		setstate mg42_flag_1 default
	}

	built final
	{
		setstate mg42_1 default

		setstate mg42_materials_1 invisible
		setstate mg42_materials_clip_1 invisible
		setstate mg42_flag_1 invisible

		wm_announce "The Axis Main Bunker MG Nest has been constructed."
	}

	decayed final
	{
		setstate mg42_1 invisible

		setstate mg42_materials_1 default
		setstate mg42_materials_clip_1 default
		setstate mg42_flag_1 default
	}

	death
	{
		setstate mg42_1 invisible
		repairmg42 mg42_1
		setstate mg42_materials_1 default
		setstate mg42_materials_clip_1 default
		setstate mg42_flag_1 default

		wm_announce "The Axis Main Bunker MG Nest has been destroyed."
	}
}

// near the door controls
mg42_clip_2
{
	spawn
	{
		wait 200
		trigger mg42_clip_2 setup
	}

	trigger setup
	{
		setstate mg42_2 invisible

		setstate mg42_materials_2 invisible
		setstate mg42_materials_clip_2 invisible
		setstate mg42_flag_2 invisible
		setstate mg42_2_toi invisible
	}

	buildstart final
	{
		setstate mg42_2 underconstruction

		setstate mg42_materials_2 default
		setstate mg42_materials_clip_2 default
		setstate mg42_flag_2 default
	}

	built final
	{
		setstate mg42_2 default

		setstate mg42_materials_2 invisible
		setstate mg42_materials_clip_2 invisible
		setstate mg42_flag_2 invisible

		wm_announce "The Axis South-East MG Nest has been constructed."
	}

	decayed final
	{
		setstate mg42_2 invisible

		setstate mg42_materials_2 default
		setstate mg42_materials_clip_2 default
		setstate mg42_flag_2 default
	}

	death
	{
		setstate mg42_2 invisible
		repairmg42 mg42_2
		setstate mg42_materials_2 default
		setstate mg42_materials_clip_2 default
		setstate mg42_flag_2 default

		wm_announce "The Axis South-East MG Nest has been destroyed."
	}
}

// overlooking West entrance to Axis Main Bunker
mg42_clip_3
{
	spawn
	{
		wait 200
		trigger mg42_clip_3 setup
	}

	trigger setup
	{
		setstate mg42_3 invisible
		setstate mg42_sbags_3 invisible
		setstate mg42_clip_3 invisible

		setstate mg42_materials_3 invisible
		setstate mg42_materials_clip_3 invisible
		setstate mg42_flag_3 invisible
		setstate mg42_3_toi invisible
	}

	buildstart final
	{
		setstate mg42_3 underconstruction
		setstate mg42_sbags_3 underconstruction

		setstate mg42_materials_3 default
		setstate mg42_materials_clip_3 default
		setstate mg42_flag_3 default
	}

	built final
	{
		setstate mg42_3 default
		setstate mg42_sbags_3 default
		setstate mg42_clip_3 default

		setstate mg42_materials_3 invisible
		setstate mg42_materials_clip_3 invisible
		setstate mg42_flag_3 invisible

		wm_announce "The Axis North-West MG Nest has been constructed."
	}

	decayed final
	{
		setstate mg42_3 invisible
		setstate mg42_sbags_3 invisible
		setstate mg42_clip_3 invisible

		setstate mg42_materials_3 default
		setstate mg42_materials_clip_3 default
		setstate mg42_flag_3 default
	}

	death
	{
		setstate mg42_3 invisible
		setstate mg42_sbags_3 invisible
		setstate mg42_clip_3 invisible
		repairmg42 mg42_3
		setstate mg42_materials_3 default
		setstate mg42_materials_clip_3 default
		setstate mg42_flag_3 default

		wm_announce "The Axis North-West MG Nest has been destroyed."
	}
}

// =====================================================
// ============ NEUTRAL COMMAND POST LMS ===============
// =====================================================

allied_compost_built_lms
{
	spawn
	{
		wait 400
		trigger allied_compost_built_lms setup

		constructible_class 2
	}

	trigger setup
	{
		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 lieutenant 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1
		sethqstatus 1 0
	}

	buildstart final
	{
		setstate allied_compost_built_model_lms underconstruction
		setstate neutral_compost_closed_clip_lms invisible
		setstate neutral_compost_closed_model_lms invisible
	}

	built final
	{
		setstate allied_compost_built_model_lms default
		setstate neutral_compost_closed_clip_lms invisible
		setstate neutral_compost_closed_model_lms invisible

		trigger allied_compost_built_model_lms enable_allied_features

		enablespeaker allies_compost_sound_lms
	}

	decayed final
	{
		setstate allied_compost_built_model_lms invisible
		setstate neutral_compost_closed_clip_lms default
		setstate neutral_compost_closed_model_lms default
	}

	death
	{
		setstate allied_compost_built_model_lms invisible
		setstate neutral_compost_closed_clip_lms default
		setstate neutral_compost_closed_model_lms default

		trigger allied_compost_built_model_lms disable_allied_features

		disablespeaker allies_compost_sound_lms
	}
}

allied_compost_built_model_lms
{
	spawn
	{
		wait 400
		setstate allied_compost_built_model_lms invisible
	}

	trigger enable_allied_features
	{
		setchargetimefactor 1 soldier 0.75
		setchargetimefactor 1 lieutenant 0.75
		setchargetimefactor 1 medic 0.75
		setchargetimefactor 1 engineer 0.75
		setchargetimefactor 1 covertops 0.75
		sethqstatus 1 1

		wm_announce	"Allied Command Post constructed. Charge speed increased!"

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed_allies"

		wm_teamvoiceannounce 1 "allies_hq_compost_constructed"

		wm_removeteamvoiceannounce 1 "allies_hq_compost_construct"
		// *---------------------------------------------------------------------------------*
	}

	trigger disable_allied_features
	{
		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 lieutenant 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1
		sethqstatus 1 0

		wm_announce	"Axis team has destroyed the Allied Command Post!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"

		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		wm_teamvoiceannounce 0 "axis_hq_compost_construct"

		wm_teamvoiceannounce 1 "allies_hq_compost_damaged"
		// *---------------------------------------------------------------------------------*
	}
}

axis_compost_built_lms
{
	spawn
	{
		wait 400
		trigger axis_compost_built_lms setup

		constructible_class 2
	}

	trigger setup
	{
		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 lieutenant 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1
		sethqstatus 0 0
	}

	buildstart final
	{
		setstate axis_compost_built_model_lms underconstruction
		setstate neutral_compost_closed_clip_lms invisible
		setstate neutral_compost_closed_model_lms invisible
	}

	built final
	{
		setstate axis_compost_built_model_lms default
		setstate neutral_compost_closed_clip_lms invisible
		setstate neutral_compost_closed_model_lms invisible

		trigger axis_compost_built_model_lms enable_axis_features

		enablespeaker axis_compost_sound_lms
	}

	decayed final
	{
		setstate axis_compost_built_model_lms invisible
		setstate neutral_compost_closed_clip_lms default
		setstate neutral_compost_closed_model_lms default
	}

	death
	{
		setstate axis_compost_built_model_lms invisible
		setstate neutral_compost_closed_clip_lms default
		setstate neutral_compost_closed_model_lms default

		trigger axis_compost_built_model_lms disable_axis_features

		disablespeaker axis_compost_sound_lms
	}
}

axis_compost_built_model_lms
{
	spawn
	{
		wait 400
		setstate axis_compost_built_model_lms invisible
	}

	trigger enable_axis_features
	{
		setchargetimefactor 0 soldier 0.75
		setchargetimefactor 0 lieutenant 0.75
		setchargetimefactor 0 medic 0.75
		setchargetimefactor 0 engineer 0.75
		setchargetimefactor 0 covertops 0.75
		sethqstatus 0 1

		wm_announce	"Axis Command Post constructed. Charge speed increased!"

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed"

		wm_teamvoiceannounce 1 "allies_hq_compost_constructed_axis"

		wm_removeteamvoiceannounce 0 "axis_hq_compost_construct"
		// *---------------------------------------------------------------------------------*
	}

	trigger disable_axis_features
	{
		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 lieutenant 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1
		sethqstatus 0 0

		wm_announce	"Allied team has destroyed the Axis Command Post!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"

		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		wm_teamvoiceannounce 0 "axis_hq_compost_damaged"

		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		// *---------------------------------------------------------------------------------*
	}
}

// ================================
// ===== REMOVE NON-LMS STUFF =====
// ================================

// Axis Main Bunker Health & Ammo Cabinets
mainbunker_hacabinet_toi
{
	spawn
	{
		wait 50
		remove
	}
}

mainbunker_hacabinet_cm_marker
{
	spawn
	{
		wait 50
		remove
	}
}

mainbunker_trigger_ammo
{
	spawn
	{
		wait 400
		remove
	}
}

mainbunker_ammocabinet
{
	spawn
	{
		wait 400
		remove
	}
}


mainbunker_ammocabinet_clip
{
	spawn
	{
		wait 400
		remove
	}
}

mainbunker_trigger_heal
{
	spawn
	{
		wait 400
		remove
	}
}

mainbunker_healthcabinet
{
	spawn
	{
		wait 400
		remove
	}
}

mainbunker_healthcabinet_clip
{
	spawn
	{
		wait 400
		remove
	}
}

// East Bunker Health & Ammo Cabinets
eastbunker_hacabinet_toi
{
	spawn
	{
		wait 50
		remove
	}
}

eastbunker_hacabinet_cm_marker
{
	spawn
	{
		wait 50
		remove
	}
}

eastbunker_trigger_ammo
{
	spawn
	{
		wait 400
		remove
	}
}

eastbunker_ammocabinet
{
	spawn
	{
		wait 400
		remove
	}
}


eastbunker_ammocabinet_clip
{
	spawn
	{
		wait 400
		remove
	}
}

eastbunker_trigger_heal
{
	spawn
	{
		wait 400
		remove
	}
}

eastbunker_healthcabinet
{
	spawn
	{
		wait 400
		remove
	}
}

eastbunker_healthcabinet_clip
{
	spawn
	{
		wait 400
		remove
	}
}

// East Bunker Command Post
neutral_compost_toi
{
	spawn
	{
		wait 50
		setstate neutral_compost_toi invisible
	}
}

neutral_compost_clip
{
	spawn
	{
		wait 400
		remove
	}
}

neutral_compost_closed_clip
{
	spawn
	{
		wait 400
		remove
	}
}

neutral_compost_closed_model
{
	spawn
	{
		wait 400
		remove
	}
}

allied_compost_built
{
	spawn
	{
		wait 400
		remove
	}
}

allied_compost_built_model
{
	spawn
	{
		wait 400
		remove
	}
}

axis_compost_built
{
	spawn
	{
		wait 400
		remove
	}
}

axis_compost_built_model
{
	spawn
	{
		wait 400
		remove
	}
}

// Allied Beach Assualt Ramp
beachplanks
{
	spawn
	{
		wait 400
		remove
	}
}

beachplanks_toi
{
	spawn
	{
		wait 400
		remove
	}
}

beachplanks_clip
{
	spawn
	{
		wait 400
		remove
	}
}

beachplanks_crates
{
	spawn
	{
		wait 400
		remove
	}
}

beachplanks_flag
{
	spawn
	{
		wait 400
		remove
	}
}

// West Bunker
westbunker_flag
{
	spawn
	{
		wait 400
		remove
	}
}

westbunker_flagbase
{
	spawn
	{
		wait 400
		remove
	}
}

// Door Controls
doorcontrols_toi
{
	spawn
	{
		wait 400
		remove
	}
}

doorcontrols
{
	spawn
	{
		wait 400
		remove
	}
}

doorcontrols_materials_clip
{
	spawn
	{
		wait 400
		remove
	}
}

doorcontrols_materials
{
	spawn
	{
		wait 400
		remove
	}
}

doorcontrols_flag
{
	spawn
	{
		wait 400
		remove
	}
}

doorcontrols_signage
{
	spawn
	{
		wait 400
		remove
	}
}

// Gun Controls
guncontrols_toi
{
	spawn
	{
		wait 400
		remove
	}
}

guncontrols
{
	spawn
	{
		wait 400
		remove
	}
}

guncontrols_smoke1
{
	spawn
	{
		wait 400
		remove
	}
}

guncontrols_smoke2
{
	spawn
	{
		wait 400
		remove
	}
}

// Doors
rightdoor_left
{
	spawn
	{
		wait 400
		remove
	}
}

rightdoor_right
{
	spawn
	{
		wait 400
		remove
	}
}

rightdoor_invtrig1
{
	spawn
	{
		wait 400
		remove
	}
}

leftdoor_left
{
	spawn
	{
		wait 400
		remove
	}
}

leftdoor_right
{
	spawn
	{
		wait 400
		remove
	}
}

leftdoor_invtrig1
{
	spawn
	{
		wait 400
		remove
	}
}

frontdoor_trigger1
{
	spawn
	{
		accum 5 set 1
		trigger frontdoor_trigger1 up
	}
	trigger up
	{
			accum 5 abort_if_not_equal 1	// Ready to run up routine == 1
			resetscript			// return to trigger that called it

			trigger frontdoor_lever1 up
			accum 5 set 0			// Setup accum for up routine
	}
	trigger down
	{
			accum 5 abort_if_not_equal 0	// Ready to run down routine == 0
			resetscript			// return to trigger that called it

			trigger frontdoor_lever1 down
			accum 5 set 1			// Setup accum for up routine
	}
	trigger off
	{
			accum 5 set 0

			trigger frontdoor_lever1 down
			wait 500
			wm_announce	"^3The Frontdoor is open now!"
	}
}

frontdoor_lever1
{
	spawn
	{
	}
	trigger down
	{
		gotomarker frontdoor_lever1_downpos 16
		playsound sound/movers/switches/butn2.wav
		trigger frontdoor_left open
		trigger frontdoor_right open
	}
	trigger up
	{
		gotomarker frontdoor_lever1_uppos 16
		playsound sound/movers/switches/switch.wav
		trigger frontdoor_left close
		trigger frontdoor_right close
	}
}

frontdoor_left
{
	spawn
	{
	}

	trigger open
	{
		wait 500
		playsound sound/movers/misc/big_gate1.wav volume 127
		wait 350
		enablespeaker frontdoor_sound
		gotomarker frontdoor_left_pc2 15 wait
		disablespeaker frontdoor_sound
		playsound sound/movers/misc/big_gate3.wav volume 127
	}

	trigger close
	{
		wait 500
		playsound sound/movers/misc/big_gate1.wav volume 127
		wait 400
		enablespeaker frontdoor_sound
		gotomarker frontdoor_left_pc1 15 wait
		disablespeaker frontdoor_sound
		playsound sound/movers/misc/big_gate3.wav volume 127
	}
}

frontdoor_right
{
	spawn
	{
	}

	trigger open
	{
		wait 850
		gotomarker frontdoor_right_pc2 18 wait
		playsound sound/movers/misc/big_gate3.wav volume 127
	}

	trigger close
	{
		wait 500
		playsound sound/movers/misc/big_gate1.wav volume 127
		wait 350
		gotomarker frontdoor_right_pc1 18 wait
		playsound sound/movers/misc/big_gate3.wav volume 127
	}
}


reardoor_right
{
	spawn
	{
		wait 400
		remove
	}
}

reardoor_left
{
	spawn
	{
		wait 400
		remove
	}
}

// Team Doors
teamdoor1
{
	spawn
	{
		wait 400
		remove
	}
}

teamdoor2
{
	spawn
	{
		wait 400
		remove
	}
}

neuetuer
{
	spawn
	{
	wait 20         
	}
	trigger open
	{   
		remove
		wm_announce	"^3Door and Barrier removed!"
	}

}

antijump1
{
	spawn
	{
	wait 20         
	}
	trigger open
	{   
		remove
	}

}

antijump2
{
	spawn
	{
	wait 20         
	}
	trigger open
	{   
		remove
	}

}

antijump3
{
	spawn
	{
	wait 20         
	}
	trigger open
	{   
		remove
	}

}

eastbunker_mg42_2
{
	spawn
	{
		wait 200
		remove
	}
}

eastbunker_mg42_mount_2
{
	spawn
	{
		wait 200
		remove
	}
}

eastbunker_mg42_1
{
	spawn
	{
		wait 200
		remove
	}
}

eastbunker_mg42_mount_1
{
	spawn
	{
		wait 200
		remove
	}
}


allied_obj1_2_toi
{
	spawn
	{
		wait 20
		remove
	}
}

guncontrols_toi
{
	spawn
	{
		wait 20
		remove
	}
}

neutral_compost_toi_lms
{
	spawn
	{
		wait 20
		setstate neutral_compost_toi_lms invisible
	}
}

mainbunker_hacabinet_toi_lms
{
	spawn
	{
		wait 20
		setstate neutral_compost_toi_lms default
	}
}

neutral_compost_built_lms
{
	spawn
	{
		wait 20
		setstate neutral_compost_built_lms invisible
	}
}

neutral_compost_built
{
	spawn
	{
		wait 20
		setstate neutral_compost_built_lms invisible
	}
}

backdoor_obj
{
	spawn
	{
		wait 20
		remove
	}
}

newdoor
{
	spawn
	{
	wait 20         
	}
	trigger open
	{   
		remove
	}

}

anti_jump_trigger1
{
	trigger kill
	{
		remove
	}
}

anti_jump_trigger2
{
	trigger kill
	{
		remove
	}
}

bunkerplanks_toi
{
    trigger show
    {
        set
        {
            origin "1844 -4354 1186"
        }
    }

    trigger hide
    {
        set
        {
            origin "1844 -4354 -1186"   // Hide the TOI fakebrush, so players don't see the "You are near ..." message when inside the bunker and the ramp is built.
        }
    }
}

// Ragnar begin: Bunker Assault Ramp script block.
// This is mainly the same scripting as for the Beach Assault Ramp.
// * accum 7 stores if the planks were build for the first time. If so, then a colored info message is written to console, else a simple message in
//   default color is written.
//   value == 1 -> planks built for the 1st time.
//   value == 0 -> 2nd or later build.
bunkerplanks
{
    spawn
    {
        wait 200
        trigger bunkerplanks setup
		set
		    {
			constructible_class 1
			health "500"
		    }

        accum 7 set 1       // accum 7 stores if the planks were built for the first time.
    }

    trigger show_materials
    {
        setstate bunkerplanks_materials      default
        setstate bunkerplanks_materials_clip default
        setstate bunkerplanks_flag           default

        trigger bunkerplanks_toi show
    }

    trigger hide_materials
    {
        setstate bunkerplanks_materials      invisible
        setstate bunkerplanks_materials_clip invisible
        setstate bunkerplanks_flag           invisible

        trigger bunkerplanks_toi hide
    }

    trigger show_planks
    {
        setstate bunkerplanks           default
        setstate bunkerplanks_model     default
        setstate bunkerplanks_spool     default
        setstate bunkerplanks_step_1    default
        setstate bunkerplanks_step_2    default
        setstate bunkerplanks_step_3    default
        setstate bunkerplanks_tire      default
    }

    trigger hide_planks
    {
        setstate bunkerplanks           invisible
        setstate bunkerplanks_model     invisible
        setstate bunkerplanks_spool     invisible
        setstate bunkerplanks_step_1    invisible
        setstate bunkerplanks_step_2    invisible
        setstate bunkerplanks_step_3    invisible
        setstate bunkerplanks_tire      invisible
    }

    trigger building_planks
    {
        setstate bunkerplanks           underconstruction
        setstate bunkerplanks_model     underconstruction
        setstate bunkerplanks_spool     underconstruction
        setstate bunkerplanks_step_1    underconstruction
        setstate bunkerplanks_step_2    underconstruction
        setstate bunkerplanks_step_3    underconstruction
        setstate bunkerplanks_tire      underconstruction
    }

    trigger setup
    {
        setstate bunkerplanks_material_hurt invisible

        trigger self hide_planks
        trigger self show_materials
    }

    buildstart final
    {
        trigger self building_planks
        trigger self show_materials
    }

    built final
    {
        trigger self show_planks
        trigger self hide_materials

        trigger self ramp_built_notify
    }

    decayed final
    {
        trigger self hide_planks
        trigger self show_materials
    }

    death
    {
        trigger self hide_planks
        trigger self show_materials

        // Just "blink" the hurt entity so anyone trapped inside the materials gets killed.
        setstate bunkerplanks_material_hurt invisible
        wait 10
        setstate bunkerplanks_material_hurt invisible

        trigger self ramp_death_notify
		
		wait 3000
		construct bunkerplanks
     }

     trigger ramp_death_notify
     {
         // No special color messages here.
        // wm_announce "The Allied Bunker Assault Ramp has been destroyed."
     }

     trigger ramp_built_notify
     {
        accum 7 trigger_if_equal 0 bunkerplanks write_plain_built_note
        accum 7 trigger_if_equal 1 bunkerplanks write_color_built_note
     }

     trigger write_color_built_note
     {
        accum 7 set 0                       // 0 indicates that the following ramp builds are not build #1.
     }

     trigger write_plain_built_note
     {
        wm_announce "The Allied Bunker Assault Ramp has been constructed."
     }
}
// Ragnar end: Bunker Assault Ramp script block.